require 'chord'

boot_node = LocalVirtualNode.new(Key.new("valor"), "localhost", 9000, 4)
boot_node.create()
nodes = []
2.times do |i|
  nodes << LocalVirtualNode.new(Key.new("valor" + i.to_s), "localhost", 9002 + i, 4)
end
    
nodes.each{|node| node.join(boot_node)}
    
nodes << boot_node

puts 'Pressione x para sair'

while true
  if gets == "x\n"
    break
  end
  i = 0
  nodes.each do |node|
    puts "----------------------------------------------------------------"
    puts "Node: " + i.to_s
    puts "Node ID: " + node.node_id.to_s
    puts "Node Pred:" + node.get_pred_list.node_id.to_s if node.get_pred_list != nil
    node.get_succ_list.each{|succ| puts "Node Succ:" + succ.node_id.to_s if succ != nil}
      
    i += 1
  end  
  puts '--------------------------------------------------------'
  puts ""
  puts 'Pressione x para sair e p para imprimir os dados dos nos.'
end



